package com.card.timer;

import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.card.match.Match;
import com.card.match.MatchManager;
import com.xiaoao.net.global.Global;

/**
 * 房间定时任务
 * @author sky
 *
 */
public class MatchJob implements Job{

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		JobDetail job = context.getJobDetail();
		String matchId = (String)job.getJobDataMap().get("matchId");
		Match match = MatchManager.getInstance().getRunMatch(matchId);
		if(matchId != null) {
			try {
				match.doTimedTask();
			} catch (Exception e) {
				Global.logErrorMessage(e);
			}
		}else{
			GameTimerManager.getInstance().deleteJob(job);
		}
	}
}
